(function() {  
    CKEDITOR.dialog.add("imageMutiUpload",  
        function(a) {  
            return {  
                title: "批量上传图片",  
                minWidth: "760px",  
                minHeight:"500px",  
                contents: [{  
                    id: "updatePicToWordNewsTab",  
                    label: "",  
                    title: "",  
                    expand: true,  
                    width: "760px",  
                    height: "500px",  
                    padding: 0,  
                    elements: [{  
                        type: "html",  
                        style: "width:760px;height:500px",  
                        html: '<iframe id="uploadFrame" src="'+realPath+'/path/image/initCKEditerImageUpload?v='+new Date().getSeconds() + '" frameborder="0"></iframe>'  
                    }]  
                }],  
                onOk: function() {  
                    var ins = a;  
                    var num = window.imgs.length;  
                    if(window.duiqi == undefined || window.duiqi == null){  
                        window.duiqi = "none";
                    }  
                    for(var i=0;i<num;i++){  
                        var imgHtml = "<p";  
                        if("center" == window.duiqi){  
                            imgHtml += " style=\"text-align:center\">";  
                        }else{  
                            imgHtml += ">";  
                        }  
                        imgHtml += "<img src=\"" + window.imgs[i] + "\" ";  
                        if("none" != window.duiqi && "center" != window.duiqi){  
                            imgHtml += "style=\"width:100%;float: " + window.duiqi + ";\"/>";  
                        }else{  
                            imgHtml += "/>";  
                        }  
                        imgHtml += "</p>";  
                        ins.insertHtml(imgHtml);  
                    }  
                    window.imgs = new Array();  
                    //点击确定按钮后的操作  
                    //a.insertHtml("编辑器追加内容");  
                }, 
                onCancel: function () {
                	var num = window.imgs.length;
                	var paths='';
                	for(var i=0;i<num;i++){  
                		paths+=window.imgs[i]+';';
                	}
                	$.post(realPath+"/path/image/deleteImages", {"paths":paths},
            				function(result) {
            					if (result.state == 'Success') {
            						if(result.content>0){
            							window.imgs = new Array(); 
            							alert("取消后，成功删除上传到服务器图片的数量："+result.content);
            						}
            					} else {
            						window.imgs = new Array();
            						alert("操作失败,原因："+result.content);
            					}
            				}
            			);
                	/*
                	try{
                		return false;
                	}catch(e){
                	}finally{
	                	bootbox.confirm({
	            		    size: null,
	            		    message: "取消会导致上传的图片从服务器删除，确定要取消吗?",
	            		    callback: function(result){
	            		    	if(result){
	            		    		
	            		    	}
	            		    }
	            		});
                	}*/
                },
                onShow: function () {  
                    document.getElementById("uploadFrame").setAttribute("src",realPath+'/path/image/initCKEditerImageUpload?v='+new Date().getSeconds()); 
                    window.imgs = new Array();
                }  
            }  
        })  
})(); 